import { defineStore } from 'pinia'
import action from '../../api/action'
export const useAddActionStore = defineStore('addAction', {
    state: () => ({
        //dialog的显示状态
        isAddAction: false,
        //添加操作的表单数据
        addActionData: {
            id: '',
            actionName: '',
            actionDate: '',
            actionLocation: '',
            actionDetails: '',
            actionType: '',
            actionCover: ''
        },
    }),
    actions: {
        setAddAction(val) {
            this.isAddAction = val
        },
        setAddActionData(val) {
            this.addActionData = val
        },
        //调用后端接口添加活动
        addAction() {
            console.log('添加活动');
            // 添加活动
            action.addActivity(this.addActionData).then(res => { 
                console.log(res);
            }).catch(err => { 
                console.log(err);
            }).finally(() => { 
                this.isAddAction = false
            });
        }
    },
    getters: {

    },
}
)